﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cos.Core.Model.Security;

namespace Cos.Module.Security
{
    public interface IUserService
    {
        /**
     * Attemps to login the user
     * 
     * @param userName The user name
     * @param password The password
     * @return The user if the loggin was successfull
     */
        //@Secured({ AuthenticatedVoter.IS_AUTHENTICATED_ANONYMOUSLY })
        User Login(String userName, String password);

        /**
         * Resets the password of a user and sends it and email
         * 
         * @param userName the user name to reset the password for
         * @param email the email used to validate that this is really the user
         * @return the new password (value might be used by an admin when the reset is done in a context where the mail will
         *         not make it)
         */
        //@Secured({ AuthenticatedVoter.IS_AUTHENTICATED_ANONYMOUSLY })
        string ForgotPassword(String userName, String email);

        /**
         * Changes the password of a user. For this change to occur the user name and old password <b>must</b> match. The
         * new password must meet the following criteria:
         * <ul>
         * <li>Be non blank</li>
         * <li>If <code>security.password.regex</code> is set in the configuration, the password must match it.</li>
         * <li>If <code>security.password.regex</code> is not set then it must match
         * <code>^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,*}$</code>. (at least 4 characters, at least one lower case, at least
         * one upper case, at least one digit.)</li>
         * </ul>
         * 
         * @param user The user whose password we must change
         * @param oldPassword The old password (used to validate that the change is valid)
         * @param newPassword The new password
         */
        //@Secured({ AuthenticatedVoter.IS_AUTHENTICATED_FULLY })
        void ChangePassword(User user, string oldPassword, string newPassword);
    }
}
